package com.focusai.efairy.utils;

/**
 * Created by Luogw on 2017/8/20.
 */

public class PrUtils {
//    0预留
//1高度
//2温度
//3压力
//4压力
//5气体浓度
//6气体浓度
//7气体浓度
//8气体浓度
//9时间
//10电压
//11电流
//12流量
//13风量
//14风速
//15剩余电流
//16烟参量
//17～127预留
//128输入检测
//129输出控制
//130～255

    public static String getNameByPt(int pt) {
        String name = "用户自定义";
        switch (pt) {
            case 0:
                name = "预留";
                break;
            case 1:
                name = "高度";
                break;
            case 2:
                name = "温度";
                break;
            case 3:
            case 4:
                name = "压力";
                break;
            case 5:
            case 6:
            case 7:
            case 8:
                name = "气体浓度";
                break;
            case 9:
                name = "时间";
                break;
            case 10:
                name = "电压";
                break;
            case 11:
                name = "电流";
                break;
            case 12:
                name = "流量";
                break;
            case 13:
                name = "风量";
                break;
            case 14:
                name = "风速";
                break;
            case 15:
//                name = "剩余电流";
                name = "漏电";
                break;
            case 16:
                name = "烟参量";
                break;
            case 17:
                name = "预留";
                break;
            case 128:
                name = "输入检测";
                break;
            case 129:
                name = "输出控制";
                break;
            default:
                break;
        }
        return name;
    }

    /**
     * 1、输入检测
     * 实时值：0-正常、1-报警
     * 阈值：0-不启用、1-常开检测、2-常闭检测
     * 2、输出检测
     * 实时值：0-正常、1-报警
     * 阈值：0-不启用、1-报警输出、2-故障输出
     **/
    public static String getInJianCeStateByRtv(int rtv) {
        if (rtv == 0) {
            return "正常";
        } else if (rtv == 1) {
            return "报警";
        }
        return "";
    }

    public static String getInJianCeStateByHtv(int htv) {
        String name = "不启用";
        switch (htv) {
            case 1:
                name = "常开检测";
                break;
            case 2:
                name = "常闭检测";
                break;
            default:
                break;
        }
        return name;
    }

    public static String getOutJianCeStateByRtv(int rtv) {
        if (rtv == 0) {
            return "正常";
        } else if (rtv == 1) {
            return "报警";
        }
        return "";
    }

    public static String getOutJianCeStateByHtv(int htv) {
        String name = "不启用";
        switch (htv) {
            case 1:
//                name = "报警输出";
                name = "报警电平输出";
                break;
            case 2:
//                name = "故障输出";
                name = " 报警脉冲输出";

                break;
            default:
                break;
        }
        return name;
    }

    public static String getUnitByPt(int pt) {
        String name = "";
        switch (pt) {
            case 1:
                name = "m";
                break;
            case 2:
                name = "°C";
                break;
            case 3:
                name = "MPa";
                break;
            case 4:
                name = "KPa";
                break;
            case 5:
                name = "LEL";
                break;
            case 6:
                name = "VOL";
                break;
            case 7:
                name = "";
                break;
            case 8:
                name = "mg/m³";
                break;
            case 9:
                name = "s";
                break;
            case 10:
                name = "V";
                break;
            case 11:
                name = "A";
                break;
            case 12:
                name = "L/S";
                break;
            case 13:
                name = "m³/min";
                break;
            case 14:
                name = "m/s";
                break;
            case 15:
                name = "mA";
                break;
            case 16:
                name = "";
                break;
            case 17:
                name = "";
                break;
            case 128:
                name = "";
                break;
            case 129:
                name = "";
                break;
            default:
                break;
        }
        return name;
    }

    public static float getRountByPt(float value, int pt) {
        if (pt == 1) {
            return (Math.round(value * 100) / 100);
        } else {
            return (Math.round(value * 10) / 10);
        }
    }

    public static float getRateByPt(int pt) {
        float name = 1.0f;
        switch (pt) {
            case 1:
                name = 0.01f;
                break;
            case 2:

            case 3:

            case 4:

            case 5:

            case 6:
                name = 0.1f;
                break;
            case 7:

            case 8:

            case 9:
                name = 1.0f;
                break;
            case 10:

            case 11:

            case 12:

            case 13:

            case 14:
                name = 0.1f;
                break;
            case 15:
                name = 1.0f;
                break;
            case 16:

            case 17:

            case 128:

            case 129:

                break;
            default:
                break;
        }
        return name;
    }
    public static int getRate2ByPt(int pt) {
        int name = 1;
        switch (pt) {
            case 1:
                name = 100;
                break;
            case 2:

            case 3:

            case 4:

            case 5:

            case 6:
                name = 10;
                break;
            case 7:

            case 8:

            case 9:
                name = 1;
                break;
            case 10:

            case 11:

            case 12:

            case 13:

            case 14:
                name = 10;
                break;
            case 15:
                name = 1;
                break;
            case 16:

            case 17:

            case 128:

            case 129:

                break;
            default:
                break;
        }
        return name;
    }

    public static int[] getRangeByPt(int pt) {
        int[] minMax = new int[2];
        switch (pt) {
            case 1:
                minMax[0] = 0;
                minMax[1] = 0;
                break;
            case 2:
                minMax[0] = 45;
                minMax[1] = 140;
                break;
            case 3:
                minMax[0] = 0;
                minMax[1] = 0;
                break;
            case 4:
                minMax[0] = 0;
                minMax[1] = 0;
                break;
            case 5:
                minMax[0] = 0;
                minMax[1] = 0;
                break;
            case 6:
                minMax[0] = 0;
                minMax[1] = 0;
                break;
            case 7:
                minMax[0] = 0;
                minMax[1] = 0;
                break;
            case 8:
                minMax[0] = 0;
                minMax[1] = 0;
                break;
            case 9:
                minMax[0] = 0;
                minMax[1] = 0;
                break;
            case 10:
                minMax[0] = 0;
                minMax[1] = 0;
                break;
            case 11:
                minMax[0] = 10;
                minMax[1] = 999;
                break;
            case 12:
                minMax[0] = 0;
                minMax[1] = 0;
                break;
            case 13:
                minMax[0] = 0;
                minMax[1] = 0;
                break;
            case 14:
                minMax[0] = 0;
                minMax[1] = 0;
                break;
            case 15:
                minMax[0] = 200;
                minMax[1] = 999;
                break;
            case 16:
                minMax[0] = 0;
                minMax[1] = 0;
                break;
            case 17:
                minMax[0] = 0;
                minMax[1] = 0;
                break;
            case 128:
                minMax[0] = 0;
                minMax[1] = 2;
                break;
            case 129:
                minMax[0] = 0;
                minMax[1] = 2;
                break;
            default:
                break;
        }
        return minMax;
    }
}
